#include<butil/logging.h>
#include<brpc/server.h>
#include<memory>
#include "main.pb.h"

class EchoServicelmpl :public demo::EchoService
{
public:
    EchoServicelmpl(){}
    ~EchoServicelmpl(){}
       virtual void Echo(::google::protobuf::RpcController* controller,
                       const ::demo::EchoRequest* request,
                       ::demo::EchoResponse* response,
                       ::google::protobuf::Closure* done) override
    {
        brpc::ClosureGuard clo(done);
        response->set_msg(request->msg() + "的响应");
    }
};


int main()
{
    //1.关闭日志
    logging::LoggingSettings log_set;
    log_set.logging_dest = logging::LoggingDestination::LOG_TO_NONE;
    logging::InitLogging(log_set);

    //2.搭建服务器
    brpc::Server server;

    EchoServicelmpl echoservice;
    server.AddService(&echoservice,brpc::SERVER_DOESNT_OWN_SERVICE);

    brpc::ServerOptions options;
    options.idle_timeout_sec = -1;
    options.num_threads = 1;

    server.Start(8080,&options);

    server.RunUntilAskedToQuit();
    return 0;
}